﻿using Sustainalytics.Entities;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ClientDW.Entities
{
    public class GCPrincipleEventIndicatorExtended : IEqualityComparer<GCPrincipleEventIndicatorExtended>, IEntity
    {
        public Guid Id { get; set; }
        public Guid CompanyId { get; set; }
        public int PrincipleTemplateId { get; set; }
        public string IssueType { get; set; }
        public GCAssessment EventIndicatorAssessment { get; set; }
        public string EventSummary { get; set; }
        public string ImpactSummary { get; set; }
        public List<string> ImpactComments { get; set; }
        public string ManagementSummary { get; set; }
        public List<string> ManagementComments { get; set; }

        public bool Equals(GCPrincipleEventIndicatorExtended x, GCPrincipleEventIndicatorExtended y)
        {
            if (x == null && y == null)
                return true;

            if (x == null || y == null)
                return false;

            return
                x.Id == y.Id
                && x.CompanyId == y.CompanyId
                && x.PrincipleTemplateId == y.PrincipleTemplateId
                && x.IssueType == y.IssueType
                && x.EventIndicatorAssessment == y.EventIndicatorAssessment
                && x.EventSummary == y.EventSummary
                && x.ImpactSummary == y.ImpactSummary
                && ((x.ImpactComments == null && y.ImpactComments == null)
                    || (x.ImpactComments.SequenceEqual(y.ImpactComments)))
                && x.ManagementSummary == y.ManagementSummary
                && ((x.ManagementComments == null && y.ManagementComments == null)
                    || (x.ManagementComments.SequenceEqual(y.ManagementComments)));
        }

        public int GetHashCode(GCPrincipleEventIndicatorExtended obj)
        {
            return Id.GetHashCode();
        }
    }
}
